import { lazy } from "react";
import {createBrowserRouter} from "react-router-dom"
import { BeforeEach } from "./BeforeEach";

const Home=lazy(()=> import("../pages/Home/Home"));
const Login=lazy(()=> import("../pages/Login/Login"));
const Info=lazy(()=> import("../pages/Info/Info"));
const User=lazy(()=> import("../pages/User/User"));
const Tabbar=lazy(()=> import("../pages/Tabbar/Tabbar"));
const Seach=lazy(()=> import("../pages/Seach/Seach"));
const ListCity=lazy(()=> import("../pages/LListCity/ListCity"));
const Details=lazy(()=> import("../pages/Details/Details"));

export const routes=([
    {
        path:"/",
        element:<Tabbar></Tabbar>,
        children:[
            {
                path:"/",
                element:<Home></Home>
            },
            {
                path:"/info",
                element:<Info></Info>
            },
            {
                path:"/user",
                element:<User></User>
            },
        ]
    },
    {
        path:"/login",
        element:<Login></Login>
    },
    {
        path:"/seach",
        element:<Seach></Seach>
    },
    {
        path:"/listcity",
        element:<ListCity></ListCity>
    },
    {
        path:"/details",
        element:<Details></Details>
    },
])

export const priviteRoutes=createBrowserRouter(
    routes.map((v)=>{
        return {...v,element:<BeforeEach>{v.element}</BeforeEach>}
    })
)